// 引入three.js
import * as THREE from 'three';
const createConeMesh =  (size)=>{
    const group = new THREE.Group
    // size底部半径
    const height = size * 4//高度
    const geometry = new THREE.ConeGeometry( size, height, 4,1,true );
    geometry.rotateX(-Math.PI/2)
    geometry.translate(0, 0, height / 2);
    const material = new THREE.MeshLambertMaterial( {
        color: 0xccff22,
        map:new THREE.TextureLoader().load('/渐变.png'),
        transparent: true, //需要开启透明度计算，否则着色器透明度设置无效
        side:THREE.DoubleSide,
        depthTest:false,
    });
    const mesh = new THREE.Mesh( geometry, material );
    const mesh2 = mesh.clone()
    mesh2.rotateX(Math.PI);
    mesh2.position.z = height + height
    group.add(mesh,mesh2)
    function render(){
        group.rotateZ(0.05) 
        requestAnimationFrame(render)
    }
    render()
    return group
}
export {createConeMesh}
